package com.test.demo.controller;
/**
 * 王宇controller层代码
 * */


import com.test.demo.model.User;
import com.test.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController(value = "/User")
public class UserController {

    @Autowired
    private UserService userService;

    @CrossOrigin//解决跨域问题
    @RequestMapping(value = "getUIsBegin")
    public List<User> getUIsBegin(){
        System.out.println("调用角色全部类型的接口");
        List<User> listUser = userService.getUIsBegin();
        return listUser;
    }

    @CrossOrigin
    @RequestMapping(value = "/getOneuser")
    public User getOneuser(Integer uid) {
        return userService.selectByPrimaryKeyuser(uid);
    }
    @CrossOrigin
    @RequestMapping(value = "getAll1" )
    public List<User> getAll1(){
        System.out.println("调用角色全部信息的方法");
        return userService.getAll1();
    }
    @CrossOrigin
    @RequestMapping(value = "delUser",method = RequestMethod.GET)
    public int delUser(Integer uid){
        return userService.delUser(uid);
    }

    @CrossOrigin
    @RequestMapping(value = "addUser",method = RequestMethod.PUT)
    public int addUser(@RequestBody User usermodel){
       //判断传参是否为空
        if (usermodel!=null){

        }else {

        }
        return userService.insertUser(usermodel);
    }
    @CrossOrigin
    @RequestMapping(value = "updateUser",method = RequestMethod.PUT)
    public int updateUser(@RequestBody User usermodel){
        return userService.updateUser(usermodel);
    }
}
